import { createRouter, createWebHashHistory } from "vue-router"
import Movie from "../pages/Movie.vue";

// import Film from "../pages/Film.vue";
// import Cinema from "../pages/Cinema.vue";
import MovieDetail from "../pages/MovieDetail.vue"
import Buy from "../pages/Buy.vue";
import Order from "../pages/Order.vue";
import Payment from "../pages/Payment.vue";
import User from "../pages/User.vue";
import System from "../pages/System.vue";
import Login from "../pages/Login.vue";

const router = createRouter({
    history: createWebHashHistory(),
    routes: [//路由表
        { path: '/', redirect: "/movie" },
        { path: '/movie', component: Movie, meta: { title: ' 影片信息' } },
        { path: '/moviedetail', name: 'moviedetail', component: MovieDetail, meta: { title: '影片详情' } },
        // { path: '/film/:id/:type', name: 'film', component: Film, meta: { title: '影片详情' }, props: true },
        // { path: '/cinema', component: Cinema, meta: { title: '影院信息' } },
        { path: '/buy', component: Buy, name: 'buy', meta: { title: '购物车' } },
        { path: '/purchase', name: "purchase", component: () => import('../pages/Purchase/Purchase.vue'), meta: { title: '购物车' } },
        { path: '/order', component: Order, name: 'order', meta: { title: ' 订单管理' } },
        { path: '/payment', component: Payment, meta: { title: '支付模块' } },
        { path: '/user', component: User, name: 'user', meta: { title: '用户' } },
        { path: '/login', component: Login, name: 'login', meta: { title: '用户登录' } },
        { path: '/system', component: System, meta: { title: '系统管理' } },
        { path: '/:match(.*)*', component: () => import('../components/404.vue') },//处理找不到或者错误组件
    ],
    linkActiveClass: 'active'//路由响应时的样式
})
router.beforeEach((to, from, next) => {
    document.title = to.meta.title;
    next()
})
export default router